package com.azxcrm.project.system.basic.service;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.azxcrm.common.utils.StringUtils;
import com.azxcrm.project.system.basic.dao.ICustomerTypeDao;
import com.azxcrm.project.system.basic.domain.CustomerType;
import com.azxcrm.project.system.basic.service.ICustomerTypeService;

/**
 * 客户类型 服务层实现
 * 
 * @author Dustyone
 * @date 2018-08-28
 */
@Service
public class CustomerTypeServiceImpl implements ICustomerTypeService 
{
	@Autowired
	private ICustomerTypeDao customerTypeDao;
	
	/**
     * 查询客户类型信息
     * 
     * @param typeId 客户类型ID
     * @return 客户类型信息
     */
	 @Override
	public CustomerType selectCustomerTypeById(Integer typeId)
	{
	    return customerTypeDao.selectCustomerTypeById(typeId);
	}
	
	/**
     * 查询客户类型列表
     * 
     * @param customerType 客户类型信息
     * @return 客户类型集合
     */
	 @Override
	public List<CustomerType> selectCustomerTypeList(CustomerType customerType)
	{
	    return customerTypeDao.selectCustomerTypeList(customerType);
	}
	
    /**
     * 新增客户类型
     * 
     * @param customerType 客户类型信息
     * @return 结果
     */
	 @Override
	public int insertCustomerType(CustomerType customerType)
	{
	    return customerTypeDao.insertCustomerType(customerType);
	}
	
	/**
     * 修改客户类型
     * 
     * @param customerType 客户类型信息
     * @return 结果
     */
	 @Override
	public int updateCustomerType(CustomerType customerType)
	{
	    return customerTypeDao.updateCustomerType(customerType);
	}
	
	/**
     * 保存客户类型
     * 
     * @param customerType 客户类型信息
     * @return 结果
     */
	 @Override
	public int saveCustomerType(CustomerType customerType)
	{
	    Integer typeId = customerType.getTypeId();
		int rows = 0;
		if (StringUtils.isNotNull(typeId))
        {
		    rows = customerTypeDao.updateCustomerType(customerType);
		}
		else
        {
		    rows = customerTypeDao.insertCustomerType(customerType);
		}
		return rows;
	}
	
	/**
     * 删除客户类型信息
     * 
     * @param typeId 客户类型ID
     * @return 结果
     */
	 @Override
	public int deleteCustomerTypeById(Integer typeId)
	{
	    return customerTypeDao.deleteCustomerTypeById(typeId);
	}
	
	/**
     * 批量删除客户类型对象
     * 
     * @param typeIds 需要删除的数据ID
     * @return 结果
     */
	 @Override
	public int batchDeleteCustomerType(Integer[] typeIds)
	{
		return customerTypeDao.batchDeleteCustomerType(typeIds);
	}
	
}
